import matplotlib.pyplot as plt
import numpy as np
import os

def ACT():
    x_data = ['MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF']
    ind = np.arange(len(x_data))
    y_data1 = [49.10102661449022, 42.52922927713715, 43.85127966801678, 42.366597810615396, 42.69981112605942, 42.69981112605942, 43.11548739308143, 33.87553418764262, 43.80989372253808, 42.36556851019161, 44.76137687981672, 44.528524359542615]
    y_data2 = [50.46102177895379, 43.102222222222224, 44.29753289473684, 42.64162844036697, 43.27040395713108, 43.27040395713108, 43.61260075670341, 34.21199465419312, 44.16861325875966, 42.79391320683825, 45.01963584434131, 44.851116625310176]
    w = 0.2
    ax = plt.subplot(111)
    a = ax.bar(ind,y_data1,width=0.2,align='center',color='red')
    b = ax.bar(ind+w,y_data2,width=0.2,align='center', color='lightseagreen')
    ax.set_xticks(ind+w)
    ax.set_xticklabels( ('MID', 'EDF', 'INS', 'SRPT', 'FB', 'THR', 'OPTFB', 'RM', 'SEDF', 'SALL', 'FIFO', 'FEDF') )
    plt.legend((a,b),('ave ACT','worst ACT'))
    plt.autoscale(tight=True)
    plt.title('The average/worst ACT')
    plt.tight_layout()
    graph_path = os.path.dirname(os.path.abspath(__file__)) + '/graph/'
    if not os.path.isdir(graph_path):
        os.makedirs(graph_path)
    file_name = graph_path + __file__.split('/')[-1].split('.')[0]
    plt.savefig(f"{file_name}.pdf", bbox_inches='tight')
    plt.close()


if __name__ == '__main__':
    ACT()